package com.cssl.controller;

import cn.hutool.core.util.ObjectUtil;
import com.cssl.domain.dto.DtsissueDto;
import com.cssl.service.Dtsissueservice;
import com.cssl.util.InfoCode;
import com.cssl.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/issue")
public class DtsissueController {
    @Autowired
    Dtsissueservice dtsissueservice;
    /**
     * 后台问题表显示
     */
    @PostMapping("/list")
    Result dtsissuelist(@RequestBody DtsissueDto dtsissueDto){
        Map issuelist=dtsissueservice.findPageissue(dtsissueDto);
        if (issuelist==null|| ObjectUtil.isEmpty(issuelist.get("list"))) {
            return Result.result(InfoCode.QUERY_EMPTY, InfoCode.MESSAGE_QUERY_EMPTY, null, System.currentTimeMillis());
        }
        System.out.println("订单数据"+dtsissueDto.getLimit()+dtsissueDto.getPage());
        System.out.println("订单状态"+dtsissueDto.getQuestion());
        return Result.result(InfoCode.OK,InfoCode.MESSAGE_OK,issuelist,System.currentTimeMillis());
    }
    @DeleteMapping("/delete")
    Result issuedelete(@RequestParam("ids") String ids){
        boolean issuedelete=dtsissueservice.issuedelete(ids);
        System.out.println("id:"+ids);
        if(issuedelete){
            return Result.result(InfoCode.OK, "删除成功", null, System.currentTimeMillis());
        }else {
            return Result.result(InfoCode.FAILED, "删除失败", null, System.currentTimeMillis());
        }
    }
    @PostMapping("/updateissue")
    Result updateissue(@RequestBody Map updateissue){
        int update=dtsissueservice.updateissue(updateissue);
        System.out.println("信息"+updateissue.size());
        return Result.result(InfoCode.OK,InfoCode.MESSAGE_OK,update,System.currentTimeMillis());
    }

    @PostMapping("/addissue")
    Result addissue(@RequestBody Map addissue){
        int issueadd=dtsissueservice.issuebrand(addissue);
        System.out.println("信息"+addissue.size());
        return Result.result(InfoCode.OK,InfoCode.MESSAGE_OK,issueadd,System.currentTimeMillis());
    }
}
